package com.example.cinema.bindingdata;

import android.view.View;
import android.widget.ImageView;

import androidx.databinding.BindingAdapter;
import androidx.databinding.ObservableField;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.example.cinema.R;

public class LiveItemData {

    @BindingAdapter("liveimg")
    public static void Imag(View view,String url)
    {
        if(view!=null&&url!=null)
        {

            RequestOptions options = new RequestOptions()
                    .placeholder(R.mipmap.defaut_img)
                    .error(R.mipmap.defaut_img)
                    .fallback(R.mipmap.defaut_img);
            Glide.with(view).load(url)
                    .apply(options)
                    .into((ImageView) view);
        }
    }

    @BindingAdapter("liveuimg")
    public static void RoundImg(View view,String url)
    {
        if(view!=null&&url!=null)
        {
            Glide.with(view).load(url).into((ImageView) view);
        }
    }


    public ObservableField<String> image = new ObservableField<>();//直播封面
    public ObservableField<String> title = new ObservableField<>();//标题
    public ObservableField<String> plaurl= new ObservableField<>();//拉流地址
    public ObservableField<String> relay = new ObservableField<>();//直播源地址
    public ObservableField<String> livename = new ObservableField<>();//主播名

}
